<template>
     <div>
        <el-form label-width="80px" >
        <el-form-item label="科目">
          <el-input maxlength="8" minlength="1" v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="成绩">
          <el-input maxlength="8" minlength="1" v-model="form.count"></el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="submit">提交</el-button>
    </div>
</template>

<script>
    export default {
        name: 'addSub',
        data(){
            return{
                form: {}
            }
        },
        methods:{
           async submit(){
                const userid = this.$store.state.login.userInfo.userid
                const grades = JSON.stringify(this.form)
                console.log('submit------------------------',userid,grades);
                if(!userid||!grades)return
                let result = await this.$store.dispatch('gradesadd',{userid,grades})
                console.log(',,,,,,,,,,,,,,,,,,,,,,,,,,,',result);
                if(result.code === 200){
                    await this.$store.dispatch('getStudentInfo',userid)
                    this.$bus.$emit('update')
                    this.$emit('update')
                }
            }
        }
    }
</script>

<style  scoped>

</style>